package org.hibernate.criterion;

import org.hibernate.criterion.Order;
import org.hibernate.criterion.CriteriaQuery;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;

public class OrderForSql extends Order {

	private static final long serialVersionUID = 1L;
	
	private String sqlFormula;
	
    protected OrderForSql(String sqlFormula) {
        super(sqlFormula, true);
        this.sqlFormula = sqlFormula;
    }
    
    public String toString() {
        return sqlFormula;
    }
    
    public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
        return sqlFormula;
    }
    
    public static Order asc(String sqlFormula) {
        return new OrderForSql(sqlFormula);
    }
    
    public static Order desc(String sqlFormula) {
        return new OrderForSql(sqlFormula + " desc");
    }
	
}
